unit Udatamodule;

interface

uses
  SysUtils, Classes,Forms, uROClient, uROBinMessage, uROSuperTCPChannel,
  ImgList, Controls,RLLibrary_Intf;

type
  Tdm = class(TDataModule)
    ROSuperTCPChannel: TROSuperTCPChannel;
    ROBinMessage: TROBinMessage;
    ImageList1: TImageList;
    procedure DataModuleCreate(Sender: TObject);
    procedure ROSuperTCPChannelFailure(Sender: TROTransportChannel;
      anException: Exception; var aRetry: Boolean);
    procedure ROSuperTCPChannelException(Sender: TROTransportChannel;
      anException: Exception; var aRetry: Boolean);

  private
    FCurrentUser:string;
    Fiorder:IOrderService;
    Firl:IRLService;
  public
     property CurrentUser:string Read FCurrentUser  write FcurrentUser;
     function GetIOrder:IOrderService;
     function GetIRl:IRLService;
 end;

var
  dm: Tdm;

implementation
   uses IniFiles; 
{$R *.dfm}

procedure Tdm.DataModuleCreate(Sender: TObject);
   var
      ini:TIniFile;
      host:string;
      port:Integer;
begin

  ini:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'client.ini');
   try
       ROSuperTCPChannel.Active:= False;
       host:=ini.ReadString('config','server','');
       port:=ini.ReadInteger('config','port',8095);
       ROSuperTCPChannel.Host:=host;
       ROSuperTCPChannel.Port:=port;
       ROSuperTCPChannel.Active:=true;
   finally
     ini.Free;
   end;
   Fiorder:=CoOrderService.Create(ROBinMessage,ROSuperTCPChannel);
   Firl:=CoRLService.Create(ROBinMessage,ROSuperTCPChannel);

end;

procedure Tdm.ROSuperTCPChannelFailure(Sender: TROTransportChannel;
  anException: Exception; var aRetry: Boolean);
begin
    Application.Terminate;
end;

procedure Tdm.ROSuperTCPChannelException(Sender: TROTransportChannel;
  anException: Exception; var aRetry: Boolean);
begin
   aretry:=false;
end;

function Tdm.GetIOrder: IOrderService;
begin
  Result:=Fiorder;
end;

function Tdm.GetIRl: IRLService;
begin
   Result:=Firl;
end;

end.
